package demo1;

import java.util.Objects;

public class Test {
    public static void main(String[] args) {
      A a1 = new A("张三" ,1);
      A a2 = new A("张三",1) ;
        System.out.println(a1);
        System.out.println(a2);
    }
}
class A{
    String name ;
    int age ;

    public A(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        A a = (A) o;
        return age == a.age && Objects.equals(name, a.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
